package  
{
	import flash.events.Event;
	import org.flixel.*;
	import org.flixel.plugin.photonstorm.FlxButtonPlus;
	import org.flixel.plugin.photonstorm.FlxExtendedSprite;
	
	public class MainMenuState extends ExtendedFlxState
	{
		private var mainTitleText:FlxText;
		private var mainTitleSubtext:FlxText;
		private var ClickPromptButton:FlxButtonPlus;
		private var mainMenuBackground:FlxExtendedSprite;
		
		public function MainMenuState() 
		{
			mainMenuBackground = new FlxExtendedSprite(0, 0, ImageFiles.mainMenuBkg);
			add(mainMenuBackground);
			
			//title text and randomization
			if (!mainTitleText)
			{
				mainTitleText = new FlxText(0, 20, FlxG.width, "The Astrotatoes in:").setFormat(null, 30, Color.OrangeWOA, "center");
			}
			if (!mainTitleSubtext)
			{
				mainTitleSubtext = new FlxText(0, 60, FlxG.width, GameTitle.getTitle()).setFormat(null, 28, Color.OrangeWOA, "center");
			}
			add(mainTitleText);
			add(mainTitleSubtext);
			
			ClickPromptButton = new FlxButtonPlus(FlxG.width / 2 - 50, FlxG.height - 100, onScreenClick);
			ClickPromptButton.text = "Start";
			add(ClickPromptButton);
			
			addStandardGUI();
		}
		
		override public function update():void 
		{
			super.update();
		}
		
		private function onScreenClick():void
		{
			FlxG.switchState(new LightPuzzle());
		}
		
		override protected function resizeWindow(e:Event = null):void 
		{
			super.resizeWindow(e);
			
			if (mainTitleText)
			{
				mainTitleText.width = FlxG.width;
				mainTitleText.setFormat(mainTitleText.font, mainTitleText.size, mainTitleText.color, mainTitleText.alignment);
			}
			else
			{
				mainTitleText = new FlxText(0, 20, FlxG.width, "The Astrotatoes in:").setFormat(null, 30, Color.OrangeWOA, "center");
			}
			
			if (mainTitleSubtext)
			{
				mainTitleSubtext.width = FlxG.width;
				mainTitleSubtext.setFormat(mainTitleSubtext.font, mainTitleSubtext.size, mainTitleSubtext.color, mainTitleSubtext.alignment);
			}
			else
			{
				mainTitleSubtext = new FlxText(0, 60, FlxG.width, GameTitle.getTitle()).setFormat(null, 28, Color.OrangeWOA, "center");
			}
		}		
	}
}